from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector

from wpez.items import HitItem

class HitSpider(BaseSpider):
    name = "HitSpider"
    allow_domains = ["amazon.cn"]
    start_urls = ["http://www.amazon.cn/gp/product/B004PYEGE8/ref=s9_simh_gw_p147_d1_i1?pf_rd_m=A1AJ19PSB66TGU&pf_rd_s=center-1&pf_rd_r=0WXATVEJWYR6ZK356D6Q&pf_rd_t=101&pf_rd_p=58840952&pf_rd_i=899254051"]

    def parse(self, response):
        hxs = HtmlXPathSelector(response)
        price = hxs.select('//b[contains(@class, "priceLarge")]/text()').extract()
        item = HitItem()
        item['price'] = price
        return item
